package _022_1_30

type Iterator struct {
}

func (this *Iterator) hasNext() bool {
	return true
}

func (this *Iterator) next() int {
	return 0
}

type PeekingIterator struct {
	iter        *Iterator
	hasNextItem bool
	elem        int
}

func Constructor(iter *Iterator) *PeekingIterator {
	peekingIterator := &PeekingIterator{}
	peekingIterator.iter = iter
	return peekingIterator
}

func (this *PeekingIterator) hasNext() bool {
	if this.hasNextItem {
		return true
	}
	return this.iter.hasNext()
}

func (this *PeekingIterator) next() int {
	if this.hasNextItem {
		this.hasNextItem = false
		return this.elem
	}

	return this.iter.next()

}

func (this *PeekingIterator) peek() int {
	if this.hasNextItem == true {
		return this.elem
	}

	elem := this.iter.next()
	this.elem = elem
	this.hasNextItem = true
	return this.elem
}
